(function(wkbName, p1, p2) {
  // console.log('----2-----2-----', serverName, p1, p2);
  const process = require('process');
  return {
    /* 描述信息 */
    description: '创建工作条调用目录，默认添加对应server.[jt]s',
    defaultPath: 'server/*',
    includePath: ['compile'],
    // excludePath: ['node_modules', '.git', '.idea'],
    suffixMap: {
      useTypeScript(val) {
        return val === true ? {'.js': '.ts', '.jsx': '.tsx'} : null
      }
    },
    nameMap: {
      workbarTm: '{name}',
      /*useTypeScript(val) {
        return val === true ? { '.jsx.': '.tsx.' } : null;
      }*/
    },
    /* 当完成用户交互后，根据结果再进行自定义改造 */
    async afterInquirer(answer) {
      // console.log(answer);
      answer.fetchName = answer.destPath.split(/[\/\\]/).pop() || '';
      answer.serverPath = `${answer.destPath.replace(/\\/g, '/').replace(/compile\//, '')}/fetch/`;
      return answer;
    },
    prompt: [
      {
        type: 'path',
        name: 'destPath',
        message: '创建目录',
        before(curCfg) {
          // console.log(curCfg.choices);
          // console.log('======================');
          if (curCfg.choices) {
            curCfg.choices =
              curCfg.choices
                .filter((item = '') => !/\/fetch$/.test(item))
                // .map((item = '') => item.replace(/.*compile\//, ''))
                .sort((a, b) => (b > a ? -1 : 1));
          }
          // console.log(curCfg.choices);
          return curCfg;
        }
      },
      {
        type: 'input',
        name: 'name',
        message: `工作条名称`,
        async before() {
          if (wkbName) {
            return {
              default: wkbName,
            }
          }
          return {};
        },
        validate(value) {
          if (!value) {
            return `必填!`;
          }
          return true;
        }
      }, {
        type: 'input',
        name: 'funcName',
        message: '查询方法名称: ',
        default: 'query',
        validate(value) {
          if (!value) {
            return `必填！`;
          }
          return true;
        }
      }, {
        type: 'confirm',
        name: 'useTypeScript',
        message: '是否使用type-script: ',
        default: true,
      }],
  }
});